
package com.dingwen.stumybplu.result;


import java.sql.Timestamp;


/**
 * 统一结果封装返回
 *
 * @author dingwen
 * @date 2021/06/07
 */
public class ResultGenerator {
    private static final String DEFAULT_OK = "OK";

    public static Result genOkResult() {
        return new Result()
                .setCode(ResultCode.OK)
                .setMessage(DEFAULT_OK)
                .setCurrentTime(new Timestamp(System.currentTimeMillis()));
    }

    public static Result genOkResult(Object data) {
        return new Result()
                .setCode(ResultCode.OK)
                .setMessage(DEFAULT_OK)
                .setData(data)
                .setCurrentTime(new Timestamp(System.currentTimeMillis()));
    }

    public static Result genFailureResult(String message) {
        return new Result()
                .setCode(ResultCode.FAILURE)
                .setMessage(message)
                .setCurrentTime(new Timestamp(System.currentTimeMillis()));
    }
}